<template>
  <div class="demo2">
    <h2>我是Demo2组件,子组件传参:{{car}}</h2>
    <button @click="sendNumber">传给demo1组件</button>
    <Child></Child>
  </div>
</template>

<script>
import Child from "@/pages/Child";
export default {
  name: "Demo2",
  components:{Child},
  data(){
    return{
      car:'',
      number:1000
    }
  },
  methods:{
    saveCar(c){
      this.car=c
    },
    sendNumber(){
      this.$bus.$emit('getNumber',this.number)
    }
  },
  mounted() {
    this.$bus.$on('sendCar',this.saveCar)
  }
}
</script>

<style scoped>
.demo2{
  background: #bd362f;
  padding: 10px;
}
</style>